<!DOCTYPE html>
<html lang="en">
<head>
[#include "/customer/include/static.htm"]

	<link href="${path}/resources/css/main.css" rel="stylesheet" type="text/css" />
	<link href="${path}/resources/css/login.css?v=4.2" rel="stylesheet" type="text/css" />
	<link href="${path}/resources/plug/layui/css/layui.css" rel="stylesheet" type="text/css"/>
	<script src="${path}/resources/plug/layui/layui.js" type="text/javascript"></script>
    <script src="${path}/resources/js/carousel.js" type="text/javascript"></script>
	<script type="text/javascript" src="${path}/resources/js/rsa/jsbn.js"></script>
	<script type="text/javascript" src="${path}/resources/js/rsa/prng4.js"></script>
	<script type="text/javascript" src="${path}/resources/js/rsa/rng.js"></script>
	<script type="text/javascript" src="${path}/resources/js/rsa/rsa.js"></script>
	<script type="text/javascript" src="${path}/resources/js/rsa/base64.js"></script>
</head>
<body>
<!--头部-->
[#include "/customer/include/header.ftl"]
<script>
    $(function() {
        //图片切换效果
        if(typeof($('#adSwitch')[0]) != 'undefined'){
            $('#adSwitch').switchCarousel();
        };

    });



</script>
<div class="login">
    <div class="fright">
        <h4><span>登录</span><font class="fright"><a class="fontBlue" href="/forget">忘记密码</a> | <a class="fontBlue" href="/member/common/register">注册</a></font></h4>
        <form class="layui-form">
            <ul>
                <li><input class="name" name="username" placeholder="用户名" type="text" ></li>
                <li><input class="pwd" name="password" placeholder="密码" onfocus="this.value=''" type="password"></li>
                <button class="layui-btn" lay-submit style="background-color: #ff5e69;width: 320px;margin-top:3px;" lay-filter="MainForm" name="" value="" type="submit">立即登录</button>
            </ul>
        </form>
    </div>
</div>

[#--<div class="login" style="background-color: #f0f0f0">--]
	[#--<div class="login-box">--]

		[#--<p>登录 <font class="fright"><a class="fontBlue" href="/forget.html">忘记密码</a> | <a class="fontBlue" href="/member/common/register">注册</a></font></p>--]
        [#--<form class="layui-form">--]

			[#--<dl class="name">--]
				[#--<input name="username"  type="text" class="user" placeholder="请输入您的用户名/手机号/邮箱"  required lay-verify="required"  autocomplete="off"/>--]
			[#--</dl>--]

			[#--<dl class="name">--]
				[#--<input name="password"   type="password"   class="password" placeholder="请输入您的密码" required  lay-verify="required" autocomplete="off" />--]
			[#--</dl>--]

			[#--<dl class="name">--]
				[#--<input name="captcha" type="text" class="user" placeholder="请输入验证码" required  lay-verify="required" maxlength="4" style="width: 150px; margin-top: 15px;"/>--]
				[#--<img src="${path}/common/random" id="code_img" width="89" height="35" onclick="this.src = '${path}/common/random?' + Math.random();" title="点击刷新验证码" style="top: 18px" />--]
			[#--</dl>--]



			[#--<button id="submit" type="button" class="login-button" lay-submit lay-filter="MainForm">立即登录</button>--]

        [#--</form>--]
	[#--</div>--]
	[#----]

[#--</div>--]
<script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form(), $=layui.jquery;

        form.on('submit(MainForm)', function(data){
            var index = layer.load();
            $.ajax({
                url: "${path}/common/key",
                type: "GET",
                dataType: "json",
                cache: false,
                beforeSend: function() {
                    $("#submit").attr("disabled", "disabled");
                },
                success: function(resultData) {
                    var rsaKey = new RSAKey();
                    rsaKey.setPublic(b64tohex(resultData.modulus), b64tohex(resultData.exponent));
                    var pass = hex2b64(rsaKey.encrypt(data.field.password));
                    ajax({
                        url: "${path}/loginVerify",
                        type: "POST",
                        dataType: "json",
                        cache: false,
						data:{"username":data.field.username,"password":pass, "captcha":data.field.captcha},
                        success: function(result) {
                            layer.close(index);
                            $("#submit").removeAttr("disabled");
							if(result && result.type && result.type == "success"){
                                var url = GetQueryString("redirectUrl");
								if(url==''||url==null){
                                    location.href = "${path}/member/";
								}else{
                                    location.href = url;
								}

							}else{
								layer.msg(result.content,{icon:2});
                                $("#code_img").click();
							}
                        },error:function(result){
                            layer.close(index);

                        }
                    });
                }
            });
            return false;
        });
    });


    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }

</script>
[#include "/customer/include/footer.ftl"]

</body>
</html>